package cn.donting.jme.edit.ui.scenetree.meum.light;

import cn.donting.jme.edit.ui.inspector.InspectorView;
import cn.donting.jme.edit.ui.scenetree.ClipBoard;
import cn.donting.jme.edit.ui.scenetree.meum.AbsTreeMenuItem;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.LightControl;

public class DirectionalLightMenuItem extends AbsTreeMenuItem {
    public DirectionalLightMenuItem() {
        super("方向性光源");
    }

    @Override
    public boolean isAvailable(ClipBoard clipBoard) {
        return true;
    }

    @Override
    public void action(ClipBoard clipBoard) {
        Spatial selectSpatial = clipBoard.getSelectSpatial();
        DirectionalLight directionalLight = new DirectionalLight();
        selectSpatial.addLight(directionalLight);

        LightControl lightControl = new LightControl(directionalLight);
        selectSpatial.addControl(lightControl);

        InspectorView.getInstance().update(selectSpatial);
    }
}
